<template>
	<view class="content">
		<h3>成绩单</h3>
		<view class="jieguo">
			<!-- 总分 -->
			<view class="allScore">
				总分：{{score}}
			</view>
			<!-- 正确的题数 -->
			<view class="correctNum">
				正确题数：{{correctNum}}
			</view>
			<!-- 错误的题数 -->
			<view class="wrongNum">
				错误题数：{{wrongNum}}
			</view>
		</view>
		<view class="huigu" v-for="item in resultReviewList" :key="item.id">
			<!-- 题目 -->
			<view class="title">
				题目：{{item.stem}}
			</view>
			<!-- 选项 -->
			<view class="option">
				选项：{{item.option}}
			</view>
			<!-- 正确答案 -->
			<view class="correct">
				正确答案：{{item.answer}}
			</view>
			<!-- 学生的答案 -->
			<view class="myAnswer">
				我的答案：{{item.userAnswer}}
			</view>
			<!-- 分值 -->
			<view class="score">
				分值：{{item.score}}
			</view>
		</view>
	</view>
</template>

<script>
	import {result,answerReview} from '../../apis'
	export default{
		data(){
			return{
				score: 0,
				resultReviewList:[],
				correctNum:'',
				wrongNum:'',
				
			} 
		},
		onLoad(option) {
			console.log("考试id为："+option.examId)
			// //学生答题结果接口
			uni.showLoading({
			    title: '加载中'
			});
			result({
				"examId": option.examId
			}).then((res) => {
				let [err, data] = res
				console.log("分数为：" + data.data.data)
				//学生答题总分数
				this.score = data.data.data
			})
			//答题回顾接口
			answerReview({
				"examId":option.examId
			}).then((res) => {
				let [err, data] = res
				console.log("答题解析为：" +data.data.data)
				console.log("答题解析为：" +JSON.stringify(data.data.data))
				console.log("答题解析为：" +data.data.data.reviewAnswerVos)
				//获取到数据中答题回顾的内容
				console.log("答题解析为：" +JSON.stringify(data.data.data.reviewAnswerVos))
				console.log("答题解析为：" + typeof(JSON.stringify(data.data.data.reviewAnswerVos)))
				console.log("答题解析为：" + JSON.parse(JSON.stringify(data.data.data.reviewAnswerVos)))
				console.log(JSON.stringify(data.data.data.errorNum))
				this.resultReviewList = JSON.parse(JSON.stringify(data.data.data.reviewAnswerVos))
				this.correctNum = JSON.stringify(data.data.data.rightNum)
				this.wrongNum = JSON.stringify(data.data.data.errorNum)
				uni.hideLoading();
			})
		}
	}
	
</script>

<style lang="scss" scoped>
	.content{
		width: 96%;
		border-top: 2px solid #ccc;
		margin: 0 auto;
		h3{
			font-size: 18px;
			font-weight: 900;
			text-align: center;
			margin: 10px;
		}
		.jieguo{
			width: 100%;
			display: flex;
			justify-content: space-around;
		}
		.huigu{
			border: 2px dashed #ccc;
			margin-top: 10px;
			view{
				margin: 5px;
				border-bottom: 1px solid #CCE6FF;
			}
		}
	}
</style>
